<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
    <link rel="stylesheet" type="text/css" href="./css/info.css" />
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>
    <script type="text/javascript" src="./script/doT.min.js"></script>
    <script type="text/javascript" src="./script/api.js"></script>
</head>

<body>
<header class="aui-bar aui-bar-nav">
    <a class="aui-pull-left" tapmode onclick="closeWin()">
        <span class="aui-iconfont aui-icon-left"></span>
    </a>
    <div class="aui-title">运营报告</div>
</header>
<div class="aui-bar-nav-d"></div>

<!-- <div class="aui-content aui-margin-b-15">
    <ul class="aui-list aui-list-in">
        <li class="aui-list-item" tapmode onclick="news_index(36,'月运营报告')">
            <div class="aui-list-item-inner aui-list-item-arrow">
                <div class="aui-list-item-title">2018年11月运营报告</div>
            </div>
        </li>
        <li class="aui-list-item">
            <div class="aui-list-item-inner aui-list-item-arrow">
                <div class="aui-list-item-title">2018年10月运营报告</div>
            </div>
        </li>
        <li class="aui-list-item">
            <div class="aui-list-item-inner aui-list-item-arrow">
                <div class="aui-list-item-title">2018年9月运营报告</div>
            </div>
        </li>
        <li class="aui-list-item">
            <div class="aui-list-item-inner aui-list-item-arrow">
                <div class="aui-list-item-title">2018年8月运营报告</div>
            </div>
        </li>
        <li class="aui-list-item">
            <div class="aui-list-item-inner aui-list-item-arrow">
                <div class="aui-list-item-title">2018年7月运营报告</div>
            </div>
        </li>
        <li class="aui-list-item">
            <div class="aui-list-item-inner aui-list-item-arrow">
                <div class="aui-list-item-title">2018年6月运营报告</div>
            </div>
        </li>
        <li class="aui-list-item">
            <div class="aui-list-item-inner aui-list-item-arrow">
                <div class="aui-list-item-title">2018年5月运营报告</div>
            </div>
        </li>
        <li class="aui-list-item">
            <div class="aui-list-item-inner aui-list-item-arrow">
                <div class="aui-list-item-title">2018年4月运营报告</div>
            </div>
        </li>
        <li class="aui-list-item">
            <div class="aui-list-item-inner aui-list-item-arrow">
                <div class="aui-list-item-title">2018年3月运营报告</div>
            </div>
        </li>
        <li class="aui-list-item">
            <div class="aui-list-item-inner aui-list-item-arrow">
                <div class="aui-list-item-title">2018年2月运营报告</div>
            </div>
        </li>
    </ul>
</div> -->

<div id="list">
</div>
<script type='text/template' id='template'>
  <div class="aui-content aui-margin-b-15">
      <ul class="aui-list aui-list-in">
        {{~it :value:index}}
          <li class="aui-list-item" tapmode onclick="news_detail({{=value.id}})">
              <div class="aui-list-item-inner aui-list-item-arrow">
                  <div class="aui-list-item-title">{{=value.title}}</div>
              </div>
          </li>
          {{~}}
      </ul>
  </div>
</script>

</body>
<script type="text/javascript">
apiready = function() {
    var title = api.pageParam.title;
    $("#title_head").text(title);

    id = api.pageParam.id;
    fnGetNewData();
    down_refresh();
    addObserver();

};

//数据请求
function fnGetNewData(n) {

    api.showProgress({
        style: 'default',
        animationType: 'fade',
        title: '努力加载中...',
        text: '先喝杯茶...',
        modal: false
    });

    if (n) {
        page += 1;
    } else {
        page = 1;
    }
    api.ajax({
        url: webAddress + '/index.php?ctl=app_article&act=article_list',
        method: 'post',
        data: {
            values: {
                cate_id: id,
                page: page
            },
        }
    }, function(ret, err) {
        if (ret) {
            var data = ret.list;
            upDataNew(data, page);
            api.refreshHeaderLoadDone();
            api.hideProgress();
        }
    });
}

function upDataNew(data, n) {
    var template = $api.byId('template');
    var dotFn = doT.template(template.innerHTML);
    var html = dotFn(data);
    var list = $api.byId('list');

    if (n == 1) {
        $api.html(list, html);
    } else {
        if (data == '') {

            api.toast({
                msg: '没有更多了',
                duration: 2000,
                location: 'bottom'
            });
            return;
        }

        $api.append(list, html);
    }

    api.parseTapmode();
}

//上拉刷新监听
function addObserver() {
    api.addEventListener({
        name: 'scrolltobottom',
        extra: {
            threshold: 0
        }
    }, function(ret, err) {
        fnGetNewData(true);
    });
}


// 下拉刷新
function down_refresh() {

    api.setRefreshHeaderInfo({
        visible: true,
        // loadingImg: 'widget://image/refresh.png',
        bgColor: '#ccc',
        textColor: '#fff',
        textDown: '下拉刷新...',
        textUp: '松开刷新...',
        showTime: true
    }, function(ret, err) {
        fnGetNewData();
    });
}

function news_detail(id)
{
    var delay = 0;
    if(id > '335')
    {
      api.openWin({
          name: 'news_details_new',
          url: './news_details_new.html',
          bounces: false,
          delay: delay,
          slidBackEnabled: true,
          vScrollBarEnabled: false,
          pageParam: {
              id: id
          }
      });
    }
    else
    {
      api.openWin({
          name: 'news_details',
          url: './news_details.html',
          bounces: false,
          delay: delay,
          slidBackEnabled: true,
          vScrollBarEnabled: false,
          pageParam: {
              id: id
          }
      });
    }
};


    function closeWin() {
        api.closeWin({});
    }
</script>

</html>
